package com.ruoyi.web.wx.controller;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.wx.domain.PtExpVideo;
import com.ruoyi.wx.service.IPtExpVideoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author moxiu
 * @since 2021-11-13
 */
@RestController
@RequestMapping("/wx/ptExpVideo")
public class PtExpVideoController {
	@Autowired
	private IPtExpVideoService ptExpVideoService;

	@ApiOperation("查看该实验下有哪些视频")
	@GetMapping("/getVideo")
	public AjaxResult getVideo(Long expId) {
		return AjaxResult.success(ptExpVideoService.list(Wrappers.lambdaQuery(PtExpVideo.class)
		.eq(PtExpVideo::getExpId,expId)));
	}

	@ApiOperation("记录用户看了这个视频")
	@GetMapping("/recordWatch")
	public AjaxResult recordWatch(Long videoId,Long expId) {
		ptExpVideoService.recordWatch(videoId,expId);
		return AjaxResult.success("操作成功");
	}

	@ApiOperation("查询用户看了什么视频")
	@GetMapping("/allWatch")
	public AjaxResult allWatch(Long expId){
		return AjaxResult.success(ptExpVideoService.selectAllVideo(SecurityUtils.getLoginUser().getUser().getUserId(),expId));
	}


}
